<?php
include("./API.php");
include("../config.php");
tongji("qq_guanli");
$qq=$_GET['uin'];//登录者的QQ号
$skey=$_GET['skey'];//登录者的skey
$pskey=$_GET['pskey'];//登录者的pskey(qun.qq.com)
$gc=$_GET['qh'];//需要操作的群号
$uin=$_GET['qq'];//需要上管理的QQ号
$bkn=bkn($skey);
$type=$_GET['msg'];//输上/下管理
$hh=$_GET["hh"]?:"\n";//换行符号(默认\n)
if($type=="上管理"){
$url="https://qun.qq.com/cgi-bin/qun_mgr/set_group_admin";
$post='gc='.$gc.'&ul='.$uin.'&op=1&bkn='.$bkn.'';
$cookie='uin=o'.$qq.'; p_uin=o'.$qq.'; skey='.$skey.'; p_skey='.$pskey.'';
$data=get_result($url,$post,$cookie);
$arr=json_decode($data,true);
$ec=$arr['ec'];
$errcode=$arr['errcode'];
if($ec==0 and $errcode==0){
echo "".$web["ming"]."API♧QQ群上下管理".$hh."";
echo "━━━━━━━━━".$hh."";
echo "设置成功".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}else{
echo "".$web["ming"]."API♧QQ群上下管理".$hh."";
echo "━━━━━━━━━".$hh."";
echo "设置失败".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}
}else{
$url="https://qun.qq.com/cgi-bin/qun_mgr/set_group_admin";
$post='gc='.$gc.'&ul='.$uin.'&op=0&bkn='.$bkn.'';
$cookie='uin=o'.$qq.'; p_uin=o'.$qq.'; skey='.$skey.'; p_skey='.$pskey.'';
$data=get_result($url,$post,$cookie);
$arr=json_decode($data,true);
$ec=$arr['ec'];
$errcode=$arr['errcode'];
if($ec==0 and $errcode==0){
echo "".$web["ming"]."API♧QQ群上下管理".$hh."";
echo "━━━━━━━━━".$hh."";
echo "取消成功".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}else{
echo "".$web["ming"]."API♧QQ群上下管理".$hh."";
echo "━━━━━━━━━".$hh."";
echo "取消失败".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}
}

function get_result($url,$post,$cookie)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$header = array('Mozilla/5.0 (Linux; Android 7.1.2; Redmi 4X Build/N2G47H; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.72 MQQBrowser/6.2 TBS/045806 Mobile Safari/537.36 V1_AND_SQ_8.8.20_1976_YYB_D A_8082000 QQ/8.8.20.5865 NetType/WIFI WebP/0.3.0 Pixel/720 StatusBarHeight/51 SimpleUISwitch/0 QQTheme/1000 InMagicWin/0 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0');
//curl_setopt($ch,CURLOPT_POST,true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); //设置等待时间
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //设置cURL允许执行的最长秒数
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}

function bkn($skey){
    $len = strlen($skey);
    $hash = 5381;
    for ($i = 0; $i < $len; $i++) {
        $hash += ($hash << 5 & 2147483647) + ord($skey[$i]) & 2147483647;
        $hash &= 2147483647;
    }
    return $hash & 2147483647;
}
?>